
import api from '../../api/index'
// components/Team/selectTeam/selectTeam.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: Boolean,
    slist: Array, // 待选择的列表
    title: String, // 选项列表的题目
    targetID:String //对方的openid
  },

  /**
   * 组件的初始数据
   */
  data: {
    start: "点击下拉选择",
    isstart: false,
    selectTeam: '' // 选中了哪个队伍
  },

  /**
   * 组件的方法列表
   */
  methods: {
    opens: function (e) {
      switch (e.currentTarget.dataset.item) {
       case "1":
        if (this.data.isstart) {
         this.setData({
          isstart: false,
         });
        }
        else {
         this.setData({
          isstart: true,
         });
        }
        break;
      }
     },
     onclicks1: function (e) {
      var index = e.currentTarget.dataset.index;
      let name = this.data.slist[index];
      this.setData({
       isstart: false,
       isfinish: false,
       isdates: false,
       start: this.data.slist[index].name,
       selectTeam: name,
       finish: "目的地"
      })
      console.log(this.data.selectTeam)
     },
  confirm() {
    this.send()
    this.setData({
      show: false
    })
  },
  off_canvas: function(){
    this.data.show ? this.setData({show: false}) :this.setData({show: true});
   },
   cancel:function(){
     this.setData({
      show:false
     })
   },
   send:function(){
    var file = this.data.selectTeam
    var targetID = this.data.targetID
  
    var action = this.data.title=="选择发送的简历"?"sendResume":"sendWorks"
    var params = {file,targetID,action}
    console.log(params)
    api.file.send(params).then(res=>{
      console.log(res.result.data.stats)
    })
  }
  }
  
})
